package com.xioaming.coupon.feign.hystrix;

import com.xiaoming.coupon.vo.CommonResponse;
import com.xiaoming.coupon.vo.SettlementInfo;
import com.xioaming.coupon.feign.SettlementClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author xiaoming
 * @Date 2020/6/17
 */
@Component
@Slf4j
public class SettlementClientHystrix implements SettlementClient {

    /**
     * 优惠券计算规则
     * @param settlementInfo
     * @return
     */
    @Override
    public CommonResponse<SettlementInfo> computeRule(SettlementInfo settlementInfo) {
        log.error("[eureka-client-coupon-settlement] computeRule request error");

        settlementInfo.setEmploy(false);
        settlementInfo.setCost(-1.0);

        return new CommonResponse<>(
                -1,
                "[eureka-client-coupon-settlement]",
                settlementInfo
        );
    }
}
